package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlCheckConfig;
import com.ruoyi.sl.service.ISlCheckConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 复核配置Controller
 * 
 * @author admin
 * @date 2024-06-29
 */
@RestController
@RequestMapping("/sl/checkconfig")
public class SlCheckConfigController extends BaseController
{
    @Autowired
    private ISlCheckConfigService slCheckConfigService;

    /**
     * 查询复核配置列表
     */
    @PreAuthorize("@ss.hasPermi('sl:checkconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlCheckConfig slCheckConfig)
    {
        startPage();
        List<SlCheckConfig> list = slCheckConfigService.selectSlCheckConfigList(slCheckConfig);
        return getDataTable(list);
    }

    /**
     * 导出复核配置列表
     */
    @PreAuthorize("@ss.hasPermi('sl:checkconfig:export')")
    @Log(title = "复核配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlCheckConfig slCheckConfig)
    {
        List<SlCheckConfig> list = slCheckConfigService.selectSlCheckConfigList(slCheckConfig);
        ExcelUtil<SlCheckConfig> util = new ExcelUtil<SlCheckConfig>(SlCheckConfig.class);
        util.exportExcel(response, list, "复核配置数据");
    }

    /**
     * 获取复核配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:checkconfig:query')")
    @GetMapping(value = "/{checkcfgId}")
    public AjaxResult getInfo(@PathVariable("checkcfgId") Long checkcfgId)
    {
        return success(slCheckConfigService.selectSlCheckConfigByCheckcfgId(checkcfgId));
    }

    /**
     * 新增复核配置
     */
    @PreAuthorize("@ss.hasPermi('sl:checkconfig:add')")
    @Log(title = "复核配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlCheckConfig slCheckConfig)
    {
        return toAjax(slCheckConfigService.insertSlCheckConfig(slCheckConfig));
    }

    /**
     * 修改复核配置
     */
    @PreAuthorize("@ss.hasPermi('sl:checkconfig:edit')")
    @Log(title = "复核配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlCheckConfig slCheckConfig)
    {
        return toAjax(slCheckConfigService.updateSlCheckConfig(slCheckConfig));
    }

    /**
     * 删除复核配置
     */
    @PreAuthorize("@ss.hasPermi('sl:checkconfig:remove')")
    @Log(title = "复核配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{checkcfgIds}")
    public AjaxResult remove(@PathVariable Long[] checkcfgIds)
    {
        return toAjax(slCheckConfigService.deleteSlCheckConfigByCheckcfgIds(checkcfgIds));
    }
}
